package io.bluerain.javafx;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

/**
 * Created by foredawn on 15-8-26.
 * javafx应用程序 第一个小案例
 */
public class HelloWorld extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("JavaFX Simple App.");
        final Label label = new Label();
        label.setText("我是一个标签");
        Button button = new Button();
        button.setText("点击我");
        button.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                label.setText("Hello World!");
            }
        });
        BorderPane pane = new BorderPane();
        pane.setTop(button);
        pane.setBottom(label);
        Group root = new Group(pane);
        primaryStage.setScene(new Scene(root, 400, 300));
        primaryStage.show();

    }
}
